﻿using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;

using Core.Localization;
using Core.Model;
using Core.Model.Column;

namespace Model.FMEA
{
    [Export(typeof(IExaminationModel))]
    public class FmeaModel : IExaminationModel
	{
		#region Constructor

		[ImportingConstructor]
		public FmeaModel(LocalizationManager localizationManager)
		{
			_localizationManager = localizationManager;
		}

		#endregion

		#region Private fields
		
		private readonly LocalizationManager _localizationManager;

		private const string _name = "Model.FMEA:Strings:FMEA";

	    private readonly IEnumerable<ExaminationColumn> _columns = new[]
		                                                      {
			                                                      new ExaminationColumn("Model.FMEA:Strings:Object", ColumnType.Regular),
			                                                      new ExaminationColumn("Model.FMEA:Strings:Component", ColumnType.Regular),
			                                                      new ExaminationColumn("Model.FMEA:Strings:Failure_mode", ColumnType.Regular),
			                                                      new ExaminationColumn("Model.FMEA:Strings:Failure_effect", ColumnType.Regular),
			                                                      new ExaminationColumn("Model.FMEA:Strings:Failure_detection_method", ColumnType.Regular)
		                                                      };

		#endregion

		#region IExaminationModel implementation

		public string Name { get { return  _localizationManager.Localize(_name); } }

		public IEnumerable<ExaminationColumn> Columns { get { return _columns.Select(column => new ExaminationColumn(_localizationManager.Localize(column.Name), column.Type)); } }

		#endregion
    }
}